//
//  UIImageView+ZKChain.m
//  ChainFun
//
//  Created by 洪绵卫 on 2022/1/10.
//

#import "UIImageView+ZKChain.h"

@implementation UIImageView (ZKChain)

+ (UIImageView * _Nonnull (^)(void))zk_allocInit{
    return ^{
         UIImageView *v = [[UIImageView alloc]init];
        return v;
    };
}

+ (UIImageView * _Nonnull (^)(CGRect))zk_allocInitWithFrame{
    return ^(CGRect rect){
        UIImageView * v = [[UIImageView alloc]initWithFrame:rect];
        return v;
    };
}

- (UIImageView * _Nonnull (^)(CGRect))zk_frame{
    return ^(CGRect rect){
        self.frame = rect;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(UIColor * _Nonnull))zk_backgroundColor{
    return ^(UIColor *color){
        self.backgroundColor = color;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(UIView * _Nonnull))zk_addToSuperView{
    return ^(UIView *view){
        [view addSubview:self];
        return self;
    };
}

- (UIImageView * _Nonnull (^)(BOOL))zk_userInteractionEnabled{
    return ^(BOOL isUserInteractionEnabled){
        self.userInteractionEnabled = isUserInteractionEnabled;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(NSInteger))zk_tag{
    return ^(NSInteger tag){
        self.tag = tag;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(CGRect))zk_bounds;{
    return ^(CGRect rect){
        self.bounds = rect;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(CGPoint))zk_center{
    return ^(CGPoint point){
        self.center = point;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(CGFloat))zk_alpha{
    return ^(CGFloat value){
        self.alpha = value;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(BOOL))zk_hidden{
    return ^(BOOL isHidden){
        self.hidden = isHidden;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(UIColor * _Nonnull))zk_tintColor{
    return ^(UIColor *col){
        self.tintColor = col;
        return self;
    };
}

#pragma mark UIImageView 的
/// 带图片的初始化
+ (UIImageView * _Nonnull (^)(UIImage *_Nullable))zk_allocInitWithImage{
    return ^(UIImage * _Nullable img){
        UIImageView * imgV = [[UIImageView alloc]initWithImage:img];
        return imgV;
    };
}

- (UIImageView * _Nonnull (^)(UIImage *_Nullable))zk_image{
    return ^(UIImage *img){
        self.image = img;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(UIImage *_Nullable))zk_highlightedImage{
    return ^(UIImage *img){
        self.highlightedImage = img;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(BOOL))zk_highlighted{
    return ^(BOOL isHighlighted){
        self.highlighted = isHighlighted;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(NSArray<UIImage *> * _Nullable))zk_animationImages{
    return ^(NSArray<UIImage *> * images){
        self.animationImages = images;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(NSArray<UIImage *> * _Nullable))zk_highlightedAnimationImages{
    return ^(NSArray<UIImage *> * images){
        self.highlightedAnimationImages = images;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(NSTimeInterval))zk_animationDuration{
    return ^(NSTimeInterval interval){
        self.animationDuration = interval;
        return self;
    };
}

- (UIImageView * _Nonnull (^)(NSInteger))zk_animationRepeatCount{
    return ^(NSInteger count){
        self.animationRepeatCount = count;
        return self;
    };
}

#pragma mark 对应UIImageView 的一些方法
- (UIImageView * _Nonnull (^)(void))zk_startAnimating{
    return ^(){
        [self startAnimating];
        return self;
    };
}

- (UIImageView * _Nonnull (^)(void))zk_stopAnimating{
    return ^(){
        [self stopAnimating];
        return self;
    };
}
@end
